package com.ibm.cognos.imt.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * Created with IntelliJ IDEA.
 * User: eric
 * Date: 3/14/14
 * Time: 2:02 PM
 * To change this template use File | Settings | File Templates.
 */

@Configuration
@PropertySource("BIServer.properties")
public class BiServerConfig {

    @Value("${BiServerIP}")
    String BiServerIP;

    @Value("${dispatcherPort}")
    String dispatcherPort;

    @Value("${dispatcherServlet}")
    String dispatcherServlet;

    @Value("${gatewayPort}")
    String gatewayPort;

    @Value("${gatewayCgi}")
    String gatewayCgi;

    @Value("${gatewayResourceUri}")
    String gatewayResourceUri;

    @Value("${modelPath}")
    String modelPath;

    @Bean
    BiServerConfig biServerConfig(){
        return new BiServerConfig();
    }

    public String dispatcherURI() {
        return "http://" + BiServerIP + ":" + dispatcherPort + dispatcherServlet;
    }

    public String gatewayCgi() {
        return gatewayResourceURI()+gatewayCgi;
    }

    public String gatewayPort() {
        return gatewayPort;
    }

    public String gatewayResourceURI() {
        String result =  "http://" + BiServerIP + ":" + gatewayPort + gatewayResourceUri;
        System.out.println("[gatewayResourceUri] "+result);
        return result;
    }

    public String getModelPath() {
        return modelPath;
    }

}
